package com.cungmua.app.model.response;

import android.content.Context;

import com.cungmua.app.R;
import com.cungmua.app.model.User;
import com.fasterxml.jackson.annotation.JsonProperty;

/**
 * Created by kelvin.nguyen on 6/16/14.
 */
public class LoginResponse extends CungMuaResponse {
    User user;

    public LoginResponse(@JsonProperty("Msg") String message, @JsonProperty("Code") int code) {
        super(message, code);
    }

    @Override
    public User getData() {
        return user;
    }

    @JsonProperty("Data")
    public void setData(User data) {
        this.user = data;
    }

    public boolean isLoginSuccess() {
        if (getCode() == 0)
            return true;
        return false;
    }

    public String getErrorMessage(Context context) {
        if (getCode() == 1000)
            return context.getString(R.id.invalid_email);
        else
            return getMessage();
    }
}
